package com.sanq.product.mcgs.kafka.service.impl;

import com.sanq.product.mcgs.kafka.service.CommonMQService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("commonMQService")
public class CommonMQServiceImpl implements CommonMQService {

    @Resource
    private KafkaTemplate<String, String> kafkaTemplate;
    @Resource
    private ThreadPoolTaskExecutor taskExecutor;

    @Value("${kafka.common.topic}")
    public String commonTopic;

    @Override
    public void sendMsg(String msg) {
        taskExecutor.execute(() -> kafkaTemplate.send(commonTopic, msg));
    }
}
